import { splitToLength, BoolStrWithBoolen } from '../../Utils/common'

export function pastHistory(data) {
  const {
    attr95,
    attr96,
    etiologyCheck,
    frequentBreathingPressing,
    recurringAcuteCough,
    attr97,
    attr98,
    attr99,
    attr100,
    attr101,
    attr102,
    attr103,
    attr104,
    attr105,
    attr106,
    attr107,
    attr108,
  } = data

  let str = ''

  str += attr95to96Convert(attr95, attr96)
  str += etiologyCheckToString(etiologyCheck)
  str += inPastSixMonthCheckToString(
    frequentBreathingPressing,
    recurringAcuteCough
  )
  str += attr97to98Convert(attr97, attr98)
  str += attr99to100Convert(attr99, attr100)
  str += attr101Convert(attr101)
  str += attr102Convert(attr102)
  str += attr103to104Convert(attr103, attr104)
  str += `，${BoolStrWithBoolen(attr105) ? '' : '，不'}经常眼痒、揉眼睛、眨眼`
  str += `。${
    BoolStrWithBoolen(attr106) ? '，曾' : '，没有'
  }被医生诊断为过敏性鼻炎`
  str += `，睡眠后${
    BoolStrWithBoolen(attr107) ? '有' : '没有'
  }鼻塞、打鼾、张口呼吸`

  if (attr108) str += `。其他：${attr108}`
  return str
}

function attr95to96Convert(attr95, attr96) {
  const b = BoolStrWithBoolen(attr95)
  if (b && attr96) {
    return `有重症肺炎(${attr96})`
  } else if (b) {
    return '有重症肺炎'
  }
  return '否认重症肺炎'
}

function etiologyCheckToString(etiologyCheck) {
  let str = ''
  if (etiologyCheck) str += `，病原学检查：${etiologyCheck}`
  return str
}
function inPastSixMonthCheckToString(breathing, cough) {
  let str = ''
  if (breathing) str += `，6个月内${breathing}经常性呼吸窘迫`
  if (cough) str += `，6个月内${cough}反复的急性咳嗽`
  return str
}

function attr97to98Convert(attr97, attr98) {
  const b = BoolStrWithBoolen(attr97)
  if (b && attr98) {
    return `，有药物食物过敏史(${attr98})`
  } else if (b) {
    return '，有药物食物过敏史'
  }
  return '，否认药物食物过敏史'
}

function attr99to100Convert(attr99, attr100) {
  const b = BoolStrWithBoolen(attr99)
  if (b && attr100) {
    return `，有吸入过敏原过敏史(${attr100})`
  } else if (b) {
    return '，有吸入过敏原过敏史'
  }
  return '，否认吸入过敏原过敏史'
}

function attr101Convert(attr101) {
  const b = BoolStrWithBoolen(attr101)
  if (b) {
    return `，有奶藓(婴儿湿疹)`
  }
  return '，无奶藓(婴儿湿疹)'
}

function attr102Convert(attr102) {
  const b = BoolStrWithBoolen(attr102)
  if (b) {
    return `，经常起荨麻疹(风团)`
  }
  return '，否认经常起荨麻疹(风团)'
}

function attr103to104Convert(attr103, attr104) {
  const b = BoolStrWithBoolen(attr103)
  if (b && attr104) {
    return `，经常流${attr104}、连续喷嚏、鼻痒、鼻塞`
  } else if (b) {
    return `，经常流涕、连续喷嚏、鼻痒、鼻塞`
  }
  return '，否认经常流涕、连续喷嚏、鼻痒、鼻塞'
}
